@extends('layout.admin')

@section('title')
    <title>角色列表</title>
@endsection
 
@section('css')

@endsection

@section('content')


<!-- ------------------------------------------------ 修改表单 -------------------------------------------------------- -->
<div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1">
  <div class="am-modal-dialog">
    <div class="am-modal-hd">修改权限信息
      <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
    </div>
    <div class="am-modal-bd">
    	<form class="am-form update" action="" method="post">
			{{ csrf_field() }}
			{{ method_field('put') }}
			<fieldset>
			    <div class="am-form-group am-text-left">
					<label for="doc-ipt-email-1">名称</label>
					<input type="text" class="" name="name" id="doc-ipt-email-1">
				</div>

			    <div class="am-form-group am-text-left">
					<label for="doc-ipt-email-1">显示名称</label>
					<input type="text" class="" name="display_name" id="doc-ipt-email-1">
				</div>

				<div class="am-form-group am-text-left">
					<label for="doc-ipt-pwd-1">描述</label>
					<textarea class="" name="description" rows="5" style="resize:none; height: 60px;" id="doc-ta-1"></textarea>
				</div>
				<div class="am-form-group checkboxs am-text-left">
					@foreach($permissions as $permission)
					<label class="am-checkbox-inline">
						<input type="checkbox" name="perm[]" value="{{$permission->id}}"> {{ $permission->display_name or $permission->name }}
					</label>
					@endforeach
				</div>
				<p><button type="submit" class="am-btn am-btn-primary am-btn-block">修改</button></p>
			</fieldset>
		</form>
    </div>
  </div>
</div>




<div class=" admin-content">
    <div class="daohang"></div>
    <div class=" admin-biaogelist" style="background: #fff;">
    	<div class="am-u-lg-12" style="margin-top:10px;">
    		<div class="am-u-lg-3" style="padding: 0px;">
				<section class="am-panel am-panel-default" style="padding: 0px;">
					<header class="am-panel-hd">
						<i class=" am-icon-plus-square" aria-hidden="true"></i>
						<h3 class="am-panel-title" style="display: inline-block;">添加角色</h3>
					</header>
					<div class="am-panel-bd">
						<form class="am-form add" action="{{url('admin/Roles')}}" method="post">
							{{ csrf_field() }}
							<fieldset>
							    <div class="am-form-group">
									<label for="doc-ipt-email-1">名称</label>
									<span style="color: red; font-size: 12px; text-indent: 10px;">请输入角色名称</span>
									<input type="text" class="" name="name" id="doc-ipt-email-1">
								</div>

							    <div class="am-form-group">
									<label for="doc-ipt-email-1">显示名称</label>
									<input type="text" class="" name="display_name" id="doc-ipt-email-1">
								</div>

								<div class="am-form-group">
									<label for="doc-ipt-pwd-1">描述</label>
									<textarea class="" name="description" rows="5" style="resize:none; height: 60px;" id="doc-ta-1"></textarea>
								</div>
								<div class="am-form-group checkboxes">
									@foreach($permissions as $permission)
									<label class="am-checkbox-inline">
										<input type="checkbox" name="perm[]" value="{{$permission->id}}"> {{ $permission->display_name or $permission->name }}
									</label>
									@endforeach
								</div>

								<p><button type="submit" class="am-btn am-btn-primary am-btn-block">添加</button></p>
  							</fieldset>
						</form>
					</div>
				</section>
			</div>
		
			<div class="am-fl am-u-lg-9">
					@foreach ($roles as $role)
						<section class="am-panel  {{ $role->name == 'admin' ? 'am-panel-success':'am-panel-default' }} am-u-lg-3 roled" style="padding: 0px; float: left; margin-left: 10px;">
							<header class="am-panel-hd">
								<h3 class="am-panel-title">
									<i class=" am-icon-street-view" aria-hidden="true"></i>
									{{ $role->display_name or $role->name }}
									@if ( $role->name != 'admin' )
										<form action="Roles/{{ $role->id }}" method="post" class="am-inline-block-display am-fr del">
											{{ csrf_field() }}
											{{ method_field('DELETE') }}
											<button style="border:0px; vertical-align: top; margin-top:1px; position: relative; left: 2px; background-color: rgba(255,255,255,0)" class="am-inline-block" aria-hidden="true"><i class=" am-icon-close" aria-hidden="true"></i></button>
										</form>
										<a href="javascript:;" id="updateUrl" data-role-name="{{$role->name}}"  data-am-modal="{target: '#doc-modal-1'}" class=" am-fr"><i class=" am-icon-cog" aria-hidden="true"></i></a>
									@endif
								</h3>
							</header>
							<div class="am-panel-bd perms" style="font-size: 12px;">
								@foreach ($role->perms as $perm)
									
									<p><i class=" am-icon-tags" data-perm-id="{{ $perm->id }}" aria-hidden="true">{{ $perm->display_name or $perm->name }}</i> </p>
								@endforeach
							</div>
									
							<footer class="am-panel-footer" style="font-size: 13px;">{{ $role->description or $role->name }}</footer>

						</section>
					@endforeach
			</div>
		</div>
		@include('common.footer')
	</div>
</div>
@endsection

@section('js')
	<script type="text/javascript" src="{{asset('common/IsExistsData.js')}}"></script>
   <script type="text/javascript" src="{{asset('admin/js/roles.js')}}"></script>
   <script type="text/javascript">
     	// $('.checkboxes label:first').attr('style', 'margin-left: 10px;');
   </script>
@endsection

@section('prompt')
    <div>

    </div>
@endsection
